{
  "cells": [
    {
      "cell_type": "markdown",
      "source": [
        "---\n",
        "\n",
        "📌 **This notebook has been updated [here](https://github.com/jhj0517/Whisper-WebUI.git)!**\n",
        "\n",
        "🖋 **Author**: [jhj0517](https://github.com/jhj0517/Whisper-WebUI/blob/master/notebook/whisper-webui.ipynb)\n",
        "\n",
        "😎 **Support the Project**:\n",
        "\n",
        "If you find this project useful, please consider supporting it:\n",
        "\n",
        "❤️ https://github.com/sponsors/jhj0517\n",
        "\n",
        "---"
      ],
      "metadata": {
        "id": "doKhBBXIfS21"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "#@title #(Optional) Check GPU\n",
        "#@markdown Some models may not function correctly on a CPU runtime.\n",
        "\n",
        "#@markdown so you should check your GPU setup before run.\n",
        "!nvidia-smi"
      ],
      "metadata": {
        "id": "23yZvUlagEsx",
        "cellView": "form"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "kNbSbsctxahq",
        "cellView": "form"
      },
      "outputs": [],
      "source": [
        "#@title #Installation\n",
        "#@markdown This cell will install dependencies for Whisper-WebUI!\n",
        "!git clone https://github.com/jhj0517/Whisper-WebUI.git\n",
        "%cd Whisper-WebUI\n",
        "!pip install git+https://github.com/jhj0517/jhj0517-whisper.git\n",
        "!pip install faster-whisper==1.1.1\n",
        "!pip install gradio==5.29.0\n",
        "!pip install gradio-i18n==0.3.1\n",
        "# Temporal bug fix from https://github.com/jhj0517/Whisper-WebUI/issues/256\n",
        "!pip install git+https://github.com/JuanBindez/pytubefix.git\n",
        "!pip install pyannote.audio==3.3.1\n",
        "!pip install git+https://github.com/jhj0517/ultimatevocalremover_api.git\n",
        "!pip install git+https://github.com/jhj0517/gradio-i18n.git"
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "#@title # (Optional) Mount Google Drive\n",
        "#@markdown Uploading large input files directly via UI may consume alot of time because it has to be uploaded in colab's server.\n",
        "#@markdown <br>This section is for using the input file paths from Google Drive to reduce such file uploading time.\n",
        "#@markdown <br>For example, you can first upload the input file to Google Drive and use the directroy path in the \"Input Folder Path\" input, as shown below.\n",
        "\n",
        "#@markdown ![image](https://github.com/user-attachments/assets/85330905-e3ec-4502-bc4b-b9d1c5b41aa2)\n",
        "\n",
        "#@markdown <br>And it will mount the output paths to your Google Drive's as well. This section is optional and can be ignored.\n",
        "\n",
        "\n",
        "# Mount Google Drive\n",
        "from google.colab import drive\n",
        "import os\n",
        "drive.mount('/content/drive')\n",
        "\n",
        "\n",
        "# Symlink Output Paths for Whisper-WebUI\n",
        "import os\n",
        "\n",
        "OUTPUT_DIRECTORY_PATH = '/content/drive/MyDrive/Whisper-WebUI/outputs'  # @param {type:\"string\"}\n",
        "local_output_path = '/content/Whisper-WebUI/outputs'\n",
        "os.makedirs(local_output_path, exist_ok=True)\n",
        "os.makedirs(OUTPUT_DIRECTORY_PATH, exist_ok=True)\n",
        "\n",
        "if os.path.exists(local_output_path):\n",
        "    !rm -r \"$local_output_path\"\n",
        "\n",
        "os.symlink(OUTPUT_DIRECTORY_PATH, local_output_path)\n",
        "!ls \"$local_output_path\""
      ],
      "metadata": {
        "cellView": "form",
        "id": "y2DY5oSb9Bol"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "#@title # (Optional) Configure arguments\n",
        "#@markdown This section is used to configure some command line arguments.\n",
        "\n",
        "#@markdown You can simply ignore this section and the default values will be used.\n",
        "\n",
        "USERNAME = '' #@param {type: \"string\"}\n",
        "PASSWORD = '' #@param {type: \"string\"}\n",
        "WHISPER_TYPE = 'faster-whisper' # @param [\"whisper\", \"faster-whisper\", \"insanely_fast_whisper\"]\n",
        "THEME = '' #@param {type: \"string\"}\n",
        "\n",
        "arguments = \"\"\n",
        "if USERNAME:\n",
        "  arguments += f\" --username {USERNAME}\"\n",
        "if PASSWORD:\n",
        "  arguments += f\" --password {PASSWORD}\"\n",
        "if THEME:\n",
        "  arguments += f\" --theme {THEME}\"\n",
        "if WHISPER_TYPE:\n",
        "  arguments += f\" --whisper_type {WHISPER_TYPE}\"\n",
        "\n",
        "\n",
        "#@markdown If you wonder how these arguments are used, you can see the [Wiki](https://github.com/jhj0517/Whisper-WebUI/wiki/Command-Line-Arguments)."
      ],
      "metadata": {
        "id": "Qosz9BFlGui3",
        "cellView": "form"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "PQroYRRZzQiN",
        "cellView": "form"
      },
      "outputs": [],
      "source": [
        "#@title #Run\n",
        "#@markdown Once the installation is complete, you can use public URL that is displayed.\n",
        "if 'arguments' in locals():\n",
        "  !python app.py --share --colab --allowed_path \"['/content/Whisper-WebUI/outputs']\"{arguments}\n",
        "else:\n",
        "    !python app.py --share --colab --allowed_path \"['/content/Whisper-WebUI/outputs']\""
      ]
    }
  ],
  "metadata": {
    "colab": {
      "provenance": [],
      "gpuType": "T4"
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    },
    "language_info": {
      "name": "python"
    },
    "accelerator": "GPU"
  },
  "nbformat": 4,
  "nbformat_minor": 0
}